home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectShow / Editing / TrimmerVB / frmMain.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-08  |  52.6 KB  |  1,233 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmMain 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "TrimmerVB"
  7.    ClientHeight    =   8775
  8.    ClientLeft      =   60
  9.    ClientTop       =   345
  10.    ClientWidth     =   10890
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "frmMain"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   8775
  15.    ScaleWidth      =   10890
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.TextBox txtInstruction 
  18.       Appearance      =   0  'Flat
  19.       BackColor       =   &H8000000F&
  20.       BorderStyle     =   0  'None
  21.       Height          =   1365
  22.       HideSelection   =   0   'False
  23.       Left            =   7425
  24.       Locked          =   -1  'True
  25.       MultiLine       =   -1  'True
  26.       TabIndex        =   40
  27.       TabStop         =   0   'False
  28.       Text            =   "frmMain.frx":030A
  29.       Top             =   4875
  30.       Width           =   3315
  31.    End
  32.    Begin VB.Frame fraPretty 
  33.       Enabled         =   0   'False
  34.       Height          =   4815
  35.       Left            =   7305
  36.       TabIndex        =   38
  37.       Top             =   3525
  38.       Width           =   3540
  39.       Begin VB.Timer tmrTimer 
  40.          Interval        =   1000
  41.          Left            =   600
  42.          Top             =   4330
  43.       End
  44.       Begin VB.TextBox txtCopyright 
  45.          Appearance      =   0  'Flat
  46.          BackColor       =   &H8000000F&
  47.          BorderStyle     =   0  'None
  48.          Height          =   840
  49.          Left            =   975
  50.          Locked          =   -1  'True
  51.          MultiLine       =   -1  'True
  52.          TabIndex        =   39
  53.          TabStop         =   0   'False
  54.          Text            =   "frmMain.frx":03D5
  55.          Top             =   225
  56.          Width           =   2490
  57.       End
  58.       Begin MSComDlg.CommonDialog ctrlCommonDialog 
  59.          Left            =   75
  60.          Top             =   4275
  61.          _ExtentX        =   847
  62.          _ExtentY        =   847
  63.          _Version        =   393216
  64.       End
  65.       Begin VB.Line lnAboutSeptum 
  66.          X1              =   150
  67.          X2              =   3375
  68.          Y1              =   1125
  69.          Y2              =   1125
  70.       End
  71.       Begin VB.Image imgAbout 
  72.          Height          =   765
  73.          Left            =   150
  74.          Picture         =   "frmMain.frx":0454
  75.          Stretch         =   -1  'True
  76.          Top             =   225
  77.          Width           =   765
  78.       End
  79.    End
  80.    Begin MSComctlLib.StatusBar ctrlStatusBar 
  81.       Align           =   2  'Align Bottom
  82.       Height          =   390
  83.       Left            =   0
  84.       TabIndex        =   30
  85.       Top             =   8385
  86.       Width           =   10890
  87.       _ExtentX        =   19209
  88.       _ExtentY        =   688
  89.       Style           =   1
  90.       _Version        =   393216
  91.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  92.       EndProperty
  93.    End
  94.    Begin VB.Frame fraPreviewControl 
  95.       Caption         =   "Video Preview:"
  96.       Height          =   2340
  97.       Left            =   45
  98.       TabIndex        =   25
  99.       Top             =   6000
  100.       Width           =   7190
  101.       Begin VB.CommandButton cmdSetStop 
  102.          Caption         =   "Set Trim Preview Stop Position"
  103.          Height          =   375
  104.          Left            =   150
  105.          TabIndex        =   9
  106.          ToolTipText     =   "Selects the ending point of the trim operation."
  107.          Top             =   1755
  108.          Width           =   3000
  109.       End
  110.       Begin VB.CommandButton cmdSelStart 
  111.          Caption         =   "Set Trim Preview Start Position"
  112.          Height          =   375
  113.          Left            =   150
  114.          TabIndex        =   8
  115.          ToolTipText     =   "Selects the starting point of the trim operation."
  116.          Top             =   1275
  117.          Width           =   3000
  118.       End
  119.       Begin VB.Frame fraVideoPreview 
  120.          Height          =   940
  121.          Left            =   3300
  122.          TabIndex        =   31
  123.          Top             =   1200
  124.          Width           =   3765
  125.          Begin VB.Label lblFPS 
  126.             Caption         =   "FPS:"
  127.             Height          =   255
  128.             Left            =   150
  129.             TabIndex        =   37
  130.             Top             =   300
  131.             Width           =   975
  132.          End
  133.          Begin VB.Label lblFPSValue 
  134.             Caption         =   "0"
  135.             Height          =   255
  136.             Left            =   1230
  137.             TabIndex        =   36
  138.             Top             =   300
  139.             Width           =   1005
  140.          End
  141.          Begin VB.Label lblStreams 
  142.             Caption         =   "Streams:"
  143.             Height          =   255
  144.             Left            =   150
  145.             TabIndex        =   35
  146.             Top             =   540
  147.             Width           =   975
  148.          End
  149.          Begin VB.Label lblStreamsValue 
  150.             Caption         =   "0"
  151.             Height          =   255
  152.             Left            =   1230
  153.             TabIndex        =   34
  154.             Top             =   540
  155.             Width           =   1005
  156.          End
  157.          Begin VB.Label lblVideoStream 
  158.             Caption         =   "Video Stream:"
  159.             Height          =   255
  160.             Left            =   2250
  161.             TabIndex        =   33
  162.             Top             =   300
  163.             Width           =   1005
  164.          End
  165.          Begin VB.Label lblVideoStreamValue 
  166.             Caption         =   "0"
  167.             Height          =   255
  168.             Left            =   3330
  169.             TabIndex        =   32
  170.             Top             =   300
  171.             Width           =   255
  172.          End
  173.       End
  174.       Begin VB.CommandButton cmdEnd 
  175.          Caption         =   "&End"
  176.          Height          =   375
  177.          Left            =   2190
  178.          TabIndex        =   6
  179.          ToolTipText     =   "Move to the last frame."
  180.          Top             =   300
  181.          Width           =   975
  182.       End
  183.       Begin VB.CommandButton cmdHome 
  184.          Caption         =   "&Home"
  185.          Height          =   375
  186.          Left            =   150
  187.          TabIndex        =   3
  188.          ToolTipText     =   "Move to the first frame."
  189.          Top             =   300
  190.          Width           =   975
  191.       End
  192.       Begin VB.CommandButton cmdFwdFrame 
  193.          Caption         =   ">"
  194.          Height          =   375
  195.          Left            =   1710
  196.          TabIndex        =   5
  197.          ToolTipText     =   "Move Forward one frame."
  198.          Top             =   300
  199.          Width           =   375
  200.       End
  201.       Begin VB.CommandButton cmdBackFrame 
  202.          Caption         =   "<"
  203.          Height          =   375
  204.          Left            =   1230
  205.          TabIndex        =   4
  206.          ToolTipText     =   "Move backward one frame."
  207.          Top             =   300
  208.          Width           =   375
  209.       End
  210.       Begin MSComctlLib.Slider ctrlSlider 
  211.          Height          =   375
  212.          Left            =   30
  213.          TabIndex        =   7
  214.          ToolTipText     =   "Highlighted portion of the timeline represents the selected video which will be 'Trimmed' from the source clip"
  215.          Top             =   825
  216.          Width           =   7130
  217.          _ExtentX        =   12568
  218.          _ExtentY        =   661
  219.          _Version        =   393216
  220.          Max             =   50
  221.          SelectRange     =   -1  'True
  222.          TextPosition    =   1
  223.       End
  224.       Begin VB.Label lblCurrentTimeValue 
  225.          Caption         =   "0"
  226.          Height          =   255
  227.          Left            =   5070
  228.          TabIndex        =   29
  229.          Top             =   540
  230.          Width           =   1680
  231.       End
  232.       Begin VB.Label lblCurrentTime 
  233.          Caption         =   "Current Time:"
  234.          Height          =   255
  235.          Left            =   3750
  236.          TabIndex        =   28
  237.          Top             =   540
  238.          Width           =   1125
  239.       End
  240.       Begin VB.Label lblCurrentFrameValue 
  241.          Caption         =   "0"
  242.          Height          =   255
  243.          Left            =   5070
  244.          TabIndex        =   27
  245.          Top             =   300
  246.          Width           =   1680
  247.       End
  248.       Begin VB.Label lblCurrentFrame 
  249.          Caption         =   "Current Frame:"
  250.          Height          =   255
  251.          Left            =   3750
  252.          TabIndex        =   26
  253.          Top             =   300
  254.          Width           =   1140
  255.       End
  256.    End
  257.    Begin VB.Frame fraVideoControl 
  258.       Caption         =   "Video Control:"
  259.       Height          =   2415
  260.       Left            =   45
  261.       TabIndex        =   14
  262.       Top             =   3525
  263.       Width           =   7190
  264.       Begin VB.CommandButton cmdPlayback 
  265.          Caption         =   "&Playback"
  266.          Height          =   375
  267.          Left            =   150
  268.          TabIndex        =   2
  269.          ToolTipText     =   "Plays back the video using Media Player"
  270.          Top             =   1875
  271.          Width           =   975
  272.       End
  273.       Begin VB.CommandButton cmdBrowse 
  274.          Caption         =   "&Browse..."
  275.          Height          =   375
  276.          Left            =   150
  277.          TabIndex        =   0
  278.          ToolTipText     =   "Browse for source media."
  279.          Top             =   900
  280.          Width           =   975
  281.       End
  282.       Begin VB.CommandButton cmdWrite 
  283.          Caption         =   "&Write"
  284.          Height          =   375
  285.          Left            =   150
  286.          TabIndex        =   1
  287.          ToolTipText     =   "Exports the trimmed video to an avi file."
  288.          Top             =   1380
  289.          Width           =   975
  290.       End
  291.       Begin MSComctlLib.ProgressBar ctrlProgress 
  292.          Height          =   405
  293.          Left            =   1230
  294.          TabIndex        =   42
  295.          Top             =   1350
  296.          Visible         =   0   'False
  297.          Width           =   5805
  298.          _ExtentX        =   10239
  299.          _ExtentY        =   714
  300.          _Version        =   393216
  301.          Appearance      =   1
  302.       End
  303.       Begin VB.Label lblPlaybackFileName 
  304.          BorderStyle     =   1  'Fixed Single
  305.          Caption         =   "c:\smart.avi"
  306.          Height          =   375
  307.          Left            =   1230
  308.          TabIndex        =   41
  309.          Top             =   1875
  310.          Width           =   5805
  311.       End
  312.       Begin VB.Label lblReadFileName 
  313.          BorderStyle     =   1  'Fixed Single
  314.          Height          =   375
  315.          Left            =   1230
  316.          TabIndex        =   24
  317.          Top             =   900
  318.          Width           =   5805
  319.       End
  320.       Begin VB.Label lblWriteFileName 
  321.          BorderStyle     =   1  'Fixed Single
  322.          Caption         =   "c:\smart.avi"
  323.          Height          =   375
  324.          Left            =   1230
  325.          TabIndex        =   23
  326.          Top             =   1380
  327.          Width           =   5805
  328.       End
  329.       Begin VB.Label lblStartFrame 
  330.          Caption         =   "Start Frame:"
  331.          Height          =   255
  332.          Left            =   150
  333.          TabIndex        =   22
  334.          Top             =   300
  335.          Width           =   1095
  336.       End
  337.       Begin VB.Label lblStartFrameValue 
  338.          Caption         =   "0"
  339.          Height          =   255
  340.          Left            =   1350
  341.          TabIndex        =   21
  342.          Top             =   300
  343.          Width           =   1680
  344.       End
  345.       Begin VB.Label lblStopFrame 
  346.          Caption         =   "Stop Frame:"
  347.          Height          =   255
  348.          Left            =   3270
  349.          TabIndex        =   20
  350.          Top             =   300
  351.          Width           =   1095
  352.       End
  353.       Begin VB.Label lblStopFrameValue 
  354.          Caption         =   "0"
  355.          Height          =   255
  356.          Left            =   4380
  357.          TabIndex        =   19
  358.          Top             =   300
  359.          Width           =   1680
  360.       End
  361.       Begin VB.Label lblStartTime 
  362.          Caption         =   "Start Time:"
  363.          Height          =   255
  364.          Left            =   150
  365.          TabIndex        =   18
  366.          Top             =   540
  367.          Width           =   1095
  368.       End
  369.       Begin VB.Label lblStartTimeValue 
  370.          Caption         =   "0"
  371.          Height          =   255
  372.          Left            =   1350
  373.          TabIndex        =   17
  374.          Top             =   540
  375.          Width           =   1680
  376.       End
  377.       Begin VB.Label lblStopTime 
  378.          Caption         =   "Stop Time:"
  379.          Height          =   255
  380.          Left            =   3270
  381.          TabIndex        =   16
  382.          Top             =   540
  383.          Width           =   1095
  384.       End
  385.       Begin VB.Label lblStopTimeValue 
  386.          Caption         =   "0"
  387.          Height          =   255
  388.          Left            =   4380
  389.          TabIndex        =   15
  390.          Top             =   540
  391.          Width           =   1680
  392.       End
  393.    End
  394.    Begin VB.PictureBox picPreview 
  395.       Height          =   3225
  396.       Left            =   45
  397.       ScaleHeight     =   3165
  398.       ScaleWidth      =   3480
  399.       TabIndex        =   10
  400.       Top             =   270
  401.       Width           =   3540
  402.    End
  403.    Begin VB.Label lblVideoStopFrame 
  404.       Caption         =   "Video Stop Frame:"
  405.       Height          =   240
  406.       Left            =   7305
  407.       TabIndex        =   13
  408.       Top             =   0
  409.       Width           =   3480
  410.    End
  411.    Begin VB.Label lblVideoStartFrame 
  412.       Caption         =   "Video Start Frame:"
  413.       Height          =   240
  414.       Left            =   3660
  415.       TabIndex        =   12
  416.       Top             =   0
  417.       Width           =   3555
  418.    End
  419.    Begin VB.Label lblVideoCurrentFrame 
  420.       Caption         =   "Current Video Frame:"
  421.       Height          =   240
  422.       Left            =   45
  423.       TabIndex        =   11
  424.       Top             =   0
  425.       Width           =   1515
  426.    End
  427.    Begin VB.Image imgPreviewStop 
  428.       BorderStyle     =   1  'Fixed Single
  429.       Height          =   3225
  430.       Left            =   7305
  431.       Stretch         =   -1  'True
  432.       Top             =   270
  433.       Width           =   3540
  434.    End
  435.    Begin VB.Image imgPreviewStart 
  436.       BorderStyle     =   1  'Fixed Single
  437.       Height          =   3225
  438.       Left            =   3675
  439.       Stretch         =   -1  'True
  440.       Top             =   270
  441.       Width           =   3540
  442.    End
  443. Attribute VB_Name = "frmMain"
  444. Attribute VB_GlobalNameSpace = False
  445. Attribute VB_Creatable = False
  446. Attribute VB_PredeclaredId = True
  447. Attribute VB_Exposed = False
  448. '*******************************************************************************
  449. '*       This is a part of the Microsoft DXSDK Code Samples.
  450. '*       Copyright (C) 1999-2001 Microsoft Corporation.
  451. '*       All rights reserved.
  452. '*       This source code is only intended as a supplement to
  453. '*       Microsoft Development Tools and/or SDK documentation.
  454. '*       See these sources for detailed information regarding the
  455. '*       Microsoft samples programs.
  456. '*******************************************************************************
  457. Option Explicit
  458. Option Base 0
  459. Option Compare Text
  460. Private m_dblFPS As Double                         'evaluates to the rate of the currently loaded clip (frames per second)
  461. Private m_boolDirty As Boolean                    'evaluates to true if the UI needs repainted, and the poster frame needs regrabbed
  462. Private m_nFrameCount As Long                   'evaluates to the number of frames in the current clip
  463. Private m_bstrFileName As String                 'evaluates to the filename of the currently loaded clip
  464. Private m_boolLoaded As Boolean                'evaluates to true if we have anything loaded
  465. Private m_boolHasAudio As Boolean            'evaluates to true if the current clip has audio
  466. Private m_objMediaDet As MediaDet            'evaluates to a media detector object which is used to work with stream information
  467. Private Const VIDEO_CLSID As String = "{73646976-0000-0010-8000-00AA00389B71}"  'video clsid
  468. Private Const AUDIO_CLSID As String = "{73647561-0000-0010-8000-00AA00389B71}"  'audio clsid
  469. Private Const POSTER_FRAME_FILENAME As String = "bitmap.bmp"   ' filename to write out poster frames for loading into the UI
  470. Private Const MPLAYER2_INSTALL_LOCATION As String = "c:\program files\windows media player\mplayer2.exe"  'mplayer2.exe
  471. ' **************************************************************************************************************************************
  472. ' * PRIVATE INTERFACE- FORM EVENTS
  473.             ' ******************************************************************************************************************************
  474.             ' * procedure name: Form_Load
  475.             ' * procedure description:  Occurs when a form is loaded.
  476.             ' *
  477.             ' ******************************************************************************************************************************
  478.             Private Sub Form_Load()
  479.             On Local Error GoTo ErrLine
  480.             
  481.             'disable ui
  482.             ctrlSlider.Enabled = False
  483.             cmdHome.Enabled = False
  484.             cmdEnd.Enabled = False
  485.             cmdBrowse.Enabled = True
  486.             cmdWrite.Enabled = False
  487.             cmdSelStart.Enabled = False
  488.             cmdSetStop.Enabled = False
  489.             cmdBackFrame.Enabled = False
  490.             cmdFwdFrame.Enabled = False
  491.             cmdPlayback.Enabled = False
  492.             Exit Sub
  493.             
  494. ErrLine:
  495.             Err.Clear
  496.             Exit Sub
  497.             End Sub
  498.             
  499.             ' ******************************************************************************************************************************
  500.             ' * procedure name: Form_Load
  501.             ' * procedure description:  Occurs when a form is loaded.
  502.             ' *
  503.             ' ******************************************************************************************************************************
  504.             Private Sub Form_Unload(Cancel As Integer)
  505.             On Local Error GoTo ErrLine
  506.             
  507.             'ensure the temporary file has been deleted
  508.             If File_Exists(GetTempDirectory & POSTER_FRAME_FILENAME) Then _
  509.                Call File_Delete(GetTempDirectory & POSTER_FRAME_FILENAME, False, False, False)
  510.             Exit Sub
  511.             
  512. ErrLine:
  513.             Err.Clear
  514.             Exit Sub
  515.             End Sub
  516.             
  517.             
  518.             ' ******************************************************************************************************************************
  519.             ' * procedure name: Form_Initialize
  520.             ' * procedure description:  Occurs when an application creates an instance of a Form, MDIForm, or class.
  521.             ' *
  522.             ' ******************************************************************************************************************************
  523.             Private Sub Form_Initialize()
  524.             On Local Error GoTo ErrLine
  525.             
  526.             'initalize module-level variable(s)
  527.             Set m_objMediaDet = New MediaDet
  528.             Exit Sub
  529.             
  530. ErrLine:
  531.             Err.Clear
  532.             Exit Sub
  533.             End Sub
  534.             
  535.             
  536.             ' ******************************************************************************************************************************
  537.             ' * procedure name: Form_Terminate
  538.             ' * procedure description:  Occurs when all references to an instance of a Form, MDIForm, or class are removed from memory.
  539.             ' *
  540.             ' ******************************************************************************************************************************
  541.             Private Sub Form_Terminate()
  542.             On Local Error GoTo ErrLine
  543.             
  544.             'terminate module-level object(s0
  545.             If Not m_objMediaDet Is Nothing Then Set m_objMediaDet = Nothing
  546.             Exit Sub
  547.             
  548. ErrLine:
  549.             Err.Clear
  550.             Exit Sub
  551.             End Sub
  552.             
  553.             
  554.             
  555. ' **************************************************************************************************************************************
  556. ' * PRIVATE INTERFACE- CONTROL EVENTS
  557.             ' ******************************************************************************************************************************
  558.             ' * procedure name: cmdPlayback_Click
  559.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  560.             ' *
  561.             ' ******************************************************************************************************************************
  562.             Private Sub cmdPlayback_Click()
  563.             Dim nResultant As Long
  564.             Dim bstrFileName As String
  565.             Dim bstrDirectoryName As String
  566.             On Local Error GoTo ErrLine
  567.             
  568.             'verify that the export location is valid
  569.             If File_Exists(lblPlaybackFileName.Caption) Then
  570.                'obtain the filename & directory name from the label
  571.                If InStr(1, lblPlaybackFileName.Caption, "\") > 0 Then
  572.                   bstrFileName = Right(lblPlaybackFileName.Caption, Len(lblPlaybackFileName.Caption) - InStrRev(lblPlaybackFileName.Caption, "\"))
  573.                   bstrDirectoryName = Replace(lblPlaybackFileName.Caption, bstrFileName, vbNullString)
  574.                   If Right(bstrDirectoryName, 1) = "\" Then bstrDirectoryName = Left(bstrDirectoryName, Len(bstrDirectoryName) - 1)
  575.                ElseIf InStr(1, lblPlaybackFileName.Caption, "/") > 0 Then
  576.                   bstrFileName = Right(lblPlaybackFileName.Caption, Len(lblPlaybackFileName.Caption) - InStrRev(lblPlaybackFileName.Caption, "/"))
  577.                   bstrDirectoryName = Replace(lblPlaybackFileName.Caption, bstrFileName, vbNullString)
  578.                   If Right(bstrDirectoryName, 1) = "/" Then bstrDirectoryName = Left(bstrDirectoryName, Len(bstrDirectoryName) - 1)
  579.                End If
  580.                nResultant = File_Execute(bstrDirectoryName, bstrFileName)
  581.             End If
  582.             
  583.             'verify the operation succeeded,
  584.             'if it did not then dislay an error dialog
  585.             If nResultant = 0 Then
  586.                MsgBox "The file could not be found on the specified path: " & _
  587.                              CStr(lblPlaybackFileName.Caption), vbExclamation + vbApplicationModal
  588.             End If
  589.             Exit Sub
  590.             
  591. ErrLine:
  592.             Err.Clear
  593.             Exit Sub
  594.             End Sub
  595.             ' ******************************************************************************************************************************
  596.             ' * procedure name: cmdBackFrame_Click
  597.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  598.             ' *
  599.             ' ******************************************************************************************************************************
  600.             Private Sub cmdBackFrame_Click()
  601.             Dim v As Long
  602.             On Local Error GoTo ErrLine
  603.             
  604.             v = CLng(ctrlSlider.Value)
  605.             v = (v - 1): If v < 0 Then v = 0
  606.             ctrlSlider.Value = v: m_boolDirty = True 'reset to dirty
  607.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  608.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  609.             Exit Sub
  610.             
  611. ErrLine:
  612.             Err.Clear
  613.             Exit Sub
  614.             End Sub
  615.             
  616.             
  617.             ' ******************************************************************************************************************************
  618.             ' * procedure name: cmdFwdFrame_Click
  619.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  620.             ' *
  621.             ' ******************************************************************************************************************************
  622.             Private Sub cmdFwdFrame_Click()
  623.             Dim v As Long
  624.             On Local Error GoTo ErrLine
  625.             
  626.             v = CLng(ctrlSlider.Value): v = (v + 1)
  627.             If v > m_nFrameCount Then v = m_nFrameCount
  628.             ctrlSlider.Value = v: m_boolDirty = True 'reset to dirty
  629.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  630.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  631.             Exit Sub
  632.             
  633. ErrLine:
  634.             Err.Clear
  635.             Exit Sub
  636.             End Sub
  637.             
  638.             
  639.             ' ******************************************************************************************************************************
  640.             ' * procedure name: cmdEnd_Click
  641.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  642.             ' *
  643.             ' ******************************************************************************************************************************
  644.             Private Sub cmdEnd_Click()
  645.             On Local Error GoTo ErrLine
  646.             
  647.             ctrlSlider.Value = m_nFrameCount: m_boolDirty = True 'reset to dirty
  648.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  649.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  650.             Exit Sub
  651.             
  652. ErrLine:
  653.             Err.Clear
  654.             Exit Sub
  655.             End Sub
  656.             
  657.             
  658.             ' ******************************************************************************************************************************
  659.             ' * procedure name: cmdHome_Click
  660.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  661.             ' *
  662.             ' ******************************************************************************************************************************
  663.             Private Sub cmdHome_Click()
  664.             On Local Error GoTo ErrLine
  665.             
  666.             ctrlSlider.Value = 0: m_boolDirty = True 'reset to dirty
  667.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  668.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  669.             Exit Sub
  670.             
  671. ErrLine:
  672.             Err.Clear
  673.             Exit Sub
  674.             End Sub
  675.             
  676.             
  677.             ' ******************************************************************************************************************************
  678.             ' * procedure name: cmdBrowse_Click
  679.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  680.             ' *
  681.             ' ******************************************************************************************************************************
  682.             Private Sub cmdBrowse_Click()
  683.             Dim nCount As Long
  684.             Dim bstrWriteName As String
  685.             Dim bstrStreamType As String
  686.             Dim intVideoStream As Integer
  687.             Dim objMediaDet As MediaDet
  688.             On Local Error Resume Next
  689.             
  690.             'display the common 'open' dialog
  691.             ctrlCommonDialog.CancelError = True
  692.             ctrlCommonDialog.Filter = "Video Files (*.avi;*.mov)|*.avi;*.mov|"
  693.             ctrlCommonDialog.ShowOpen
  694.             
  695.             If ctrlCommonDialog.FileName <> vbNullString Then
  696.                'assign the filename to the MediaDet
  697.                If File_Exists(ctrlCommonDialog.FileName) Then
  698.                   Set objMediaDet = New MediaDet 'instantiate
  699.                   objMediaDet.FileName = ctrlCommonDialog.FileName
  700.                Else: Exit Sub
  701.                End If
  702.             Else: Exit Sub
  703.             End If
  704.                 
  705.             'fashion a new name to write out
  706.             lblReadFileName.Caption = ctrlCommonDialog.FileName
  707.             bstrWriteName = Left$(ctrlCommonDialog.FileName, Len(ctrlCommonDialog.FileName) - 4) + "_T.avi"
  708.             lblWriteFileName.Caption = bstrWriteName: lblPlaybackFileName.Caption = bstrWriteName
  709.             
  710.             'see if there's any video and audio
  711.             m_boolHasAudio = False
  712.             
  713.             intVideoStream = -1
  714.             For nCount = 0 To objMediaDet.OutputStreams - 1
  715.                 'get the current stream
  716.                 objMediaDet.CurrentStream = nCount
  717.                 'obtain the type of stream (audio/video)
  718.                 bstrStreamType = objMediaDet.StreamTypeB
  719.                 'elect an action based on the stream type
  720.                 If bstrStreamType = VIDEO_CLSID Then
  721.                     'video stream
  722.                     intVideoStream = nCount
  723.                     Call SetDuration(objMediaDet.StreamLength, objMediaDet.FrameRate)
  724.                 ElseIf bstrStreamType = AUDIO_CLSID Then
  725.                     'audio stream
  726.                     m_boolHasAudio = True
  727.                 End If
  728.             Next
  729.             
  730.             'default error
  731.             If intVideoStream = -1 Then
  732.                 MsgBox "The Selected File does not contain a video stream.", vbExclamation
  733.                 Exit Sub
  734.             End If
  735.             
  736.             'assign the instance to module-level
  737.             If Not objMediaDet Is Nothing Then Set m_objMediaDet = objMediaDet
  738.             If ctrlCommonDialog.FileName <> vbNullString Then m_bstrFileName = ctrlCommonDialog.FileName
  739.             
  740.             'assign the stream info the the ui
  741.             lblStreamsValue.Caption = Trim(CStr(objMediaDet.OutputStreams))
  742.             lblVideoStreamValue.Caption = Trim(Str(intVideoStream))
  743.                         
  744.             ' get a poster frame to start out with
  745.             objMediaDet.WriteBitmapBits 0, picPreview.Width / 15, picPreview.Height / 15, GetTempDirectory + POSTER_FRAME_FILENAME
  746.             picPreview.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  747.             
  748.             'assign state
  749.             m_boolLoaded = True
  750.             m_boolDirty = False
  751.             
  752.             'reset scrollbar
  753.             ctrlSlider.Value = 0
  754.             Call ctrlSlider_Scroll
  755.             
  756.             'set  start/stop
  757.             Call cmdSelStart_Click
  758.             Call cmdSetStop_Click
  759.             
  760.             'enable ui
  761.             ctrlSlider.Enabled = True
  762.             cmdHome.Enabled = True
  763.             cmdEnd.Enabled = True
  764.             cmdBrowse.Enabled = True
  765.             cmdWrite.Enabled = True
  766.             cmdSelStart.Enabled = True
  767.             cmdSetStop.Enabled = True
  768.             cmdBackFrame.Enabled = True
  769.             cmdFwdFrame.Enabled = True
  770.             
  771.             'clean-up & dereference
  772.             If Not objMediaDet Is Nothing Then Set objMediaDet = Nothing
  773.             Exit Sub
  774.             
  775. ErrLine:
  776.             Err.Clear
  777.             Exit Sub
  778.             End Sub
  779.             
  780.             
  781.             
  782.             ' ******************************************************************************************************************************
  783.             ' * procedure name: cmdSelStart_Click
  784.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  785.             ' *                                       Set the start frame and show a frame for it.
  786.             ' ******************************************************************************************************************************
  787.             Private Sub cmdSelStart_Click()
  788.             On Local Error GoTo ErrLine
  789.             
  790.             If Not m_boolLoaded Then Exit Sub
  791.             
  792.             'setup the ui
  793.             lblStartTimeValue.Caption = Trim(Str(GetCurrentPos))
  794.             lblStartFrameValue.Caption = Trim(Str(ctrlSlider.Value))
  795.             lblVideoStartFrame.Caption = "Video Start Frame:" & Space(2) & Trim(Str(Round(GetCurrentPos, 2)))
  796.             
  797.             'setup the slider
  798.             If ctrlSlider.Value > ctrlSlider.SelStart Then
  799.                 ctrlSlider.SelStart = ctrlSlider.Value
  800.                 ctrlSlider.SelLength = 0
  801.             Else: ctrlSlider.SelStart = ctrlSlider.Value
  802.             End If
  803.             
  804.             'reset to dirty
  805.             m_boolDirty = True
  806.             'call the timer event proc
  807.             Call tmrTimer_Timer
  808.             'load the picture into the preview pane
  809.             imgPreviewStart.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  810.             Exit Sub
  811.             
  812. ErrLine:
  813.             Err.Clear
  814.             Exit Sub
  815.             End Sub
  816.             
  817.             
  818.             
  819.             ' ******************************************************************************************************************************
  820.             ' * procedure name: cmdSetStop_Click
  821.             ' * procedure description:   Occurs when the user presses and then releases a mouse button over an object.
  822.             ' *                                        Set the stop frame and show a frame for it
  823.             ' ******************************************************************************************************************************
  824.             Private Sub cmdSetStop_Click()
  825.             On Local Error GoTo ErrLine
  826.             
  827.             If Not m_boolLoaded Then Exit Sub
  828.             
  829.             'setup the ui
  830.             lblStopTimeValue.Caption = Trim(Str(GetCurrentPos))
  831.             lblStopFrameValue.Caption = Trim(Str(ctrlSlider.Value))
  832.             lblVideoStopFrame.Caption = "Video Stop Frame:" & Space(2) & Trim(Str(Round(GetCurrentPos, 2)))
  833.             
  834.             'setup the slider
  835.             If ctrlSlider.Value < ctrlSlider.SelStart Then
  836.                 ctrlSlider.SelStart = ctrlSlider.Value
  837.                 ctrlSlider.SelLength = 0
  838.             Else
  839.                 ctrlSlider.SelLength = ctrlSlider.Value - ctrlSlider.SelStart
  840.             End If
  841.             
  842.             'reset to dirty
  843.             m_boolDirty = True
  844.             'call the timer event proc
  845.             Call tmrTimer_Timer
  846.             'load the picture into the preview pane
  847.             imgPreviewStop.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  848.             Exit Sub
  849.             
  850. ErrLine:
  851.             Err.Clear
  852.             Exit Sub
  853.             End Sub
  854.             
  855.             
  856.             
  857.             
  858.             ' ******************************************************************************************************************************
  859.             ' * procedure name: cmdWrite_Click
  860.             ' * procedure description:   Occurs when the user presses and then releases a mouse button over an object.
  861.             ' *                                        Construct a timeline and write out the file using smart recompression.
  862.             ' ******************************************************************************************************************************
  863.             Private Sub cmdWrite_Click()
  864.             Dim nState As Long
  865.             Dim nReturnCode As Long
  866.             Dim dblPosition As Double
  867.             Dim dblDuration As Double
  868.             Dim dblStartTime As Double
  869.             Dim dblStopTime As Double
  870.             
  871.             Dim objMediaEvent As IMediaEvent
  872.             Dim objMediaPosition As IMediaPosition
  873.             Dim objFilterGraphManager As FilgraphManager
  874.             
  875.             Dim objTimeline As AMTimeline
  876.             Dim objSourceObj As AMTimelineObj
  877.             Dim objTrackObject As AMTimelineObj
  878.             Dim objAudioGroupObj As AMTimelineObj
  879.             Dim objVideoGroupObject As AMTimelineObj
  880.             
  881.             Dim objSource As AMTimelineSrc
  882.             Dim objTrack As AMTimelineTrack
  883.             Dim objAudioGroup As AMTimelineGroup
  884.             Dim objVideoGroup As AMTimelineGroup
  885.             Dim objAudioComposition As AMTimelineComp
  886.             Dim objVideoComposition As AMTimelineComp
  887.             Dim objSmartRenderEngine As New SmartRenderEngine
  888.             On Local Error GoTo ErrLine
  889.             
  890.             
  891.             'disable the form
  892.             Call DisableEverything
  893.             
  894.             
  895.             'instantiate a timeline
  896.             Set objTimeline = New AMTimeline
  897.             'create an empty node on the timeline for the video
  898.             objTimeline.CreateEmptyNode objVideoGroupObject, TIMELINE_MAJOR_TYPE_GROUP
  899.             'derive the video group object from the timeline object
  900.             Set objVideoGroup = objVideoGroupObject
  901.             'set the media type of the video group
  902.             objVideoGroup.SetMediaTypeForVB 0
  903.             'append the video group to the timeline
  904.             objTimeline.AddGroup objVideoGroup
  905.             
  906.             
  907.             
  908.             'create an empty node on the timeline for the track
  909.             objTimeline.CreateEmptyNode objTrackObject, TIMELINE_MAJOR_TYPE_TRACK
  910.             'obtain a composition from the video group
  911.             Set objVideoComposition = objVideoGroup
  912.             'inset the track into the composition
  913.             objVideoComposition.VTrackInsBefore objTrackObject, -1
  914.             'derive the track object
  915.             Set objTrack = objTrackObject
  916.             
  917.             
  918.             
  919.             'create an empty node on the timeline for the source clip
  920.             objTimeline.CreateEmptyNode objSourceObj, TIMELINE_MAJOR_TYPE_SOURCE
  921.             'derive the source clip from the timeline object
  922.             Set objSource = objSourceObj
  923.             'query the ui for duration times
  924.             If m_dblFPS > 0 Then
  925.                dblDuration = ctrlSlider.SelLength / m_dblFPS
  926.                dblStartTime = ctrlSlider.SelStart / m_dblFPS
  927.                dblStopTime = dblStartTime + dblDuration
  928.             Else
  929.                dblDuration = ctrlSlider.SelLength / 15
  930.                dblStartTime = ctrlSlider.SelStart / 15
  931.                dblStopTime = dblStartTime + dblDuration
  932.             End If
  933.             'verify start/stop times
  934.             If dblStopTime = 0 Then
  935.                dblStopTime = 1
  936.             ElseIf dblStartTime = dblStopTime Then
  937.                dblStopTime = dblStartTime + 1
  938.             End If
  939.             'set the start/stop times to the source clip
  940.             objSourceObj.SetStartStop2 0, dblDuration
  941.             objSource.SetMediaTimes2 dblStartTime, dblStopTime
  942.             objSource.SetMediaName m_bstrFileName
  943.             'append the source clip to the track
  944.             objTrack.SrcAdd objSourceObj
  945.             
  946.             
  947.             
  948.             If m_boolHasAudio Then
  949.                'create an empty node on the timeline for the audio group
  950.                objTimeline.CreateEmptyNode objAudioGroupObj, TIMELINE_MAJOR_TYPE_GROUP
  951.                'derive the audio group form the timeline object
  952.                Set objAudioGroup = objAudioGroupObj
  953.                'set the media type of the audio group
  954.                objAudioGroup.SetMediaTypeForVB 1
  955.                'append the group to the timeline
  956.                objTimeline.AddGroup objAudioGroup
  957.                
  958.                'create an empty node on the timeline for the track
  959.                objTimeline.CreateEmptyNode objTrackObject, TIMELINE_MAJOR_TYPE_TRACK
  960.                'derive a composition from the audio group
  961.                Set objAudioComposition = objAudioGroup
  962.                'insetr the track into the composition
  963.                objAudioComposition.VTrackInsBefore objTrackObject, -1
  964.                'derive a track object from the timeline object
  965.                Set objTrack = objTrackObject
  966.                
  967.                'create an empty node for the source clip
  968.                objTimeline.CreateEmptyNode objSourceObj, TIMELINE_MAJOR_TYPE_SOURCE
  969.                'derive a source object from the timeline object
  970.                Set objSource = objSourceObj
  971.                'set the start/stop times from the ui
  972.                objSourceObj.SetStartStop2 0, dblDuration
  973.                objSource.SetMediaTimes2 dblStartTime, dblStopTime
  974.                objSource.SetMediaName m_bstrFileName
  975.                'add the source to the track
  976.                objTrack.SrcAdd objSourceObj
  977.             End If
  978.             
  979.             
  980.             
  981.             ' set the recompression format of the video group
  982.             objVideoGroup.SetRecompFormatFromSource objSource
  983.             'set the timeline to the render engine
  984.             objSmartRenderEngine.SetTimelineObject objTimeline
  985.             'connect-up the render engine
  986.             objSmartRenderEngine.ConnectFrontEnd
  987.             'obtain a reference to the filter graph for the timeline
  988.             objSmartRenderEngine.GetFilterGraph objFilterGraphManager
  989.             'add a file writer and mux filter to the filtergraph
  990.             AddFileWriterAndMux objFilterGraphManager, lblWriteFileName.Caption
  991.             'render the output pins & prepare to proceed with smart render
  992.             RenderGroupPins objSmartRenderEngine, objTimeline
  993.             'run the graph, in turn creating the given file
  994.             objFilterGraphManager.Run
  995.             'obtain a media event from the filtergraph manager
  996.             Set objMediaEvent = objFilterGraphManager
  997.             'obtain the position within the graph
  998.             Set objMediaPosition = objFilterGraphManager
  999.             
  1000.             
  1001.             
  1002.             'display the progress during render
  1003.             ctrlProgress.Value = 0
  1004.             ctrlProgress.Visible = True: lblWriteFileName.Visible = False
  1005.             Do: DoEvents
  1006.                   'set the progress bar's current position
  1007.                   If dblDuration > 0 Then
  1008.                         If Round(ctrlProgress.Value, 0) = 100 Then
  1009.                            ctrlProgress.Value = 0
  1010.                         Else: ctrlProgress.Value = (ctrlProgress.Value + 1)
  1011.                         End If
  1012.                   End If
  1013.                   'wait until the file has been written, and exit
  1014.                   If Not objMediaEvent Is Nothing Then
  1015.                   Call objMediaEvent.WaitForCompletion(100, nReturnCode)
  1016.                   If nReturnCode = 1 Then Exit Do
  1017.                   Else: Exit Do
  1018.                   End If
  1019.             Loop
  1020. Cleanup:
  1021.             
  1022.             'clean-up code
  1023.             ctrlProgress.Value = 100
  1024.             ctrlProgress.Visible = False: lblWriteFileName.Visible = True
  1025.             cmdWrite.Enabled = True: Call EnableEverything
  1026.             
  1027.             'scrap the render engine
  1028.             If Not objSmartRenderEngine Is Nothing Then objSmartRenderEngine.ScrapIt
  1029.             'clean-up & dereference quartz object(s)
  1030.             If Not objMediaEvent Is Nothing Then Set objMediaEvent = Nothing
  1031.             If Not objMediaPosition Is Nothing Then Set objMediaPosition = Nothing
  1032.             If Not objFilterGraphManager Is Nothing Then Set objFilterGraphManager = Nothing
  1033.             'clean-up & dereference dexter timeline object(s)
  1034.             If Not objTimeline Is Nothing Then Set objTimeline = Nothing
  1035.             If Not objSourceObj Is Nothing Then Set objSourceObj = Nothing
  1036.             If Not objTrackObject Is Nothing Then Set objTrackObject = Nothing
  1037.             If Not objAudioGroupObj Is Nothing Then Set objAudioGroupObj = Nothing
  1038.             If Not objVideoGroupObject Is Nothing Then Set objVideoGroupObject = Nothing
  1039.             'clean-up & dereference dexter timeline object(s)
  1040.             If Not objTrack Is Nothing Then Set objTrack = Nothing
  1041.             If Not objSource Is Nothing Then Set objSource = Nothing
  1042.             If Not objAudioGroup Is Nothing Then Set objAudioGroup = Nothing
  1043.             If Not objVideoGroup Is Nothing Then Set objVideoGroup = Nothing
  1044.             If Not objAudioComposition Is Nothing Then Set objAudioComposition = Nothing
  1045.             If Not objVideoComposition Is Nothing Then Set objVideoComposition = Nothing
  1046.             If Not objSmartRenderEngine Is Nothing Then Set objSmartRenderEngine = Nothing
  1047.             Exit Sub
  1048.             
  1049. ErrLine:
  1050.             Select Case Err.Number
  1051.                 Case 5 'Invalid procedure call or argument
  1052.                    Call MsgBox("Error creating file.  Verify that the start/stop times are valid before continuing.", vbExclamation + vbApplicationModal)
  1053.                    Err.Clear: GoTo Cleanup
  1054.                 Case 287 'Application-defined or object-defined error
  1055.                    Err.Clear: Resume Next
  1056.                 Case -2147024864 'The process cannot access the file because it is being used by another process.
  1057.                    Call MsgBox(Err.Description, vbExclamation + vbApplicationModal): Err.Clear: GoTo Cleanup
  1058.                 Case Else 'unknown error
  1059.                    Call MsgBox(Err.Description, vbExclamation + vbApplicationModal): Err.Clear: GoTo Cleanup
  1060.             End Select
  1061.             Exit Sub
  1062.             End Sub
  1063.             
  1064.             ' ******************************************************************************************************************************
  1065.             ' * procedure name: ctrlSlider_Scroll
  1066.             ' * procedure description:  ctrlSlider scroll event.
  1067.             ' *
  1068.             ' ******************************************************************************************************************************
  1069.             Private Sub ctrlSlider_Scroll()
  1070.             On Local Error GoTo ErrLine
  1071.             
  1072.             If m_boolLoaded Then
  1073.                'reset the label caption's
  1074.                lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  1075.                If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  1076.                'reset to dirty
  1077.                m_boolDirty = True
  1078.             End If
  1079.             Exit Sub
  1080.             
  1081. ErrLine:
  1082.             Err.Clear
  1083.             Exit Sub
  1084.             End Sub
  1085.             
  1086.             ' ******************************************************************************************************************************
  1087.             ' * procedure name: tmrTimer_Timer
  1088.             ' * procedure description:  Occurs when a preset interval for a Timer control has elapsed.
  1089.             ' *                                        If the UI is dirty, go grab a video frame and draw it.
  1090.             ' ******************************************************************************************************************************
  1091.             Private Sub tmrTimer_Timer()
  1092.             On Local Error GoTo ErrLine
  1093.             
  1094.             If m_boolDirty Then
  1095.                'reset to not dirty
  1096.                m_boolDirty = False
  1097.                'write out the current frame to the given bitmap file
  1098.                m_objMediaDet.WriteBitmapBits GetCurrentPos, picPreview.Width / 15, picPreview.Height / 15, GetTempDirectory + POSTER_FRAME_FILENAME
  1099.                'load the picture into the preview pane
  1100.                picPreview.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  1101.             End If
  1102.             Exit Sub
  1103.             
  1104. ErrLine:
  1105.             Err.Clear
  1106.             Exit Sub
  1107.             End Sub
  1108.             
  1109.             
  1110.             
  1111. ' **************************************************************************************************************************************
  1112. ' * PRIVATE INTERFACE- PROCEDURES
  1113.             ' ******************************************************************************************************************************
  1114.             ' * procedure name: EnableEverything
  1115.             ' * procedure description:  Enables most controls on the form.
  1116.             ' *
  1117.             ' ******************************************************************************************************************************
  1118.             Private Sub EnableEverything()
  1119.             On Local Error GoTo ErrLine
  1120.             
  1121.             'update ui
  1122.             ctrlSlider.Enabled = True
  1123.             cmdBrowse.Enabled = True
  1124.             cmdWrite.Enabled = True
  1125.             cmdSelStart.Enabled = True
  1126.             cmdSetStop.Enabled = True
  1127.             cmdBackFrame.Enabled = True
  1128.             cmdFwdFrame.Enabled = True
  1129.             cmdPlayback.Enabled = True
  1130.             Exit Sub
  1131.             
  1132. ErrLine:
  1133.             Err.Clear
  1134.             Exit Sub
  1135.             End Sub
  1136.             
  1137.             
  1138.             
  1139.             ' ******************************************************************************************************************************
  1140.             ' * procedure name: DisableEverything
  1141.             ' * procedure description:  Disables most controls on the form.
  1142.             ' *
  1143.             ' ******************************************************************************************************************************
  1144.             Private Sub DisableEverything()
  1145.             On Local Error GoTo ErrLine
  1146.             
  1147.             'update ui
  1148.             ctrlSlider.Enabled = False
  1149.             cmdBrowse.Enabled = False
  1150.             cmdWrite.Enabled = False
  1151.             cmdSelStart.Enabled = False
  1152.             cmdSetStop.Enabled = False
  1153.             cmdBackFrame.Enabled = False
  1154.             cmdFwdFrame.Enabled = False
  1155.             cmdPlayback.Enabled = False
  1156.             Exit Sub
  1157.             
  1158. ErrLine:
  1159.             Err.Clear
  1160.             Exit Sub
  1161.             End Sub
  1162.             
  1163.             
  1164.             ' ******************************************************************************************************************************
  1165.             ' * procedure name: SetDuration
  1166.             ' * procedure description:  Sets the status within the context of the ui given the duration and the rate.
  1167.             ' *
  1168.             ' ******************************************************************************************************************************
  1169.             Private Sub SetDuration(dblDuration As Double, dblFPS As Double)
  1170.             On Local Error GoTo ErrLine
  1171.             
  1172.             'set module-level data
  1173.             m_dblFPS = dblFPS
  1174.             m_nFrameCount = (dblDuration * dblFPS)
  1175.             
  1176.             'setup / update the UI
  1177.             ctrlSlider.SelStart = 0
  1178.             ctrlSlider.SelLength = 0
  1179.             ctrlSlider.Min = 0
  1180.             ctrlSlider.Max = m_nFrameCount
  1181.             ctrlSlider.LargeChange = (m_nFrameCount / 10)
  1182.             ctrlSlider.SmallChange = (m_nFrameCount / 100)
  1183.             ctrlSlider.TickFrequency = 100
  1184.             lblStartTimeValue.Caption = 0
  1185.             lblStopTimeValue.Caption = 0
  1186.             lblFPSValue.Caption = Trim(Str(Format(dblFPS, "##.##")))
  1187.             Exit Sub
  1188.             
  1189. ErrLine:
  1190.             Err.Clear
  1191.             Exit Sub
  1192.             End Sub
  1193.             
  1194.             
  1195.             
  1196.             ' ******************************************************************************************************************************
  1197.             ' * procedure name: GetDuration
  1198.             ' * procedure description:  Returns the duration of the loaded media given the frame count divided by the rate.
  1199.             ' *
  1200.             ' ******************************************************************************************************************************
  1201.             Private Function GetDuration() As Double
  1202.             On Local Error GoTo ErrLine
  1203.             
  1204.             If m_dblFPS = 0 Then Exit Function
  1205.             GetDuration = CDbl((m_nFrameCount / m_dblFPS))
  1206.             Exit Function
  1207.             
  1208. ErrLine:
  1209.             Err.Clear
  1210.             Exit Function
  1211.             End Function
  1212.             
  1213.             
  1214.             
  1215.             ' ******************************************************************************************************************************
  1216.             ' * procedure name: GetCurrentPos
  1217.             ' * procedure description:  Returns the current position given the slider's value divided by the rate.
  1218.             ' *
  1219.             ' ******************************************************************************************************************************
  1220.             Private Function GetCurrentPos() As Double
  1221.             On Local Error GoTo ErrLine
  1222.             
  1223.             If m_dblFPS = 0 Then Exit Function
  1224.             If IsNumeric(ctrlSlider.Value) Then
  1225.                GetCurrentPos = (ctrlSlider.Value / m_dblFPS)
  1226.             End If
  1227.             Exit Function
  1228.             
  1229. ErrLine:
  1230.             Err.Clear
  1231.             Exit Function
  1232.             End Function
  1233.